//
//  ZH_LookTeacherViewModel.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/11/6.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_LookTeacherViewModel.h"
//找老师详情
#define MechanismDetail       @"/api/Mechanism/detail"
//找老师
#define MechanismTeacher      @"/api/Mechanism/teacher"
//教师课程
#define MechanismTeacher_course   @"/api/Mechanism/teacher_course"
@implementation ZH_LookTeacherViewModel
//找老师详情
- (void)teacherDetailResultBlock:(WBRequestResultBlock)resultBlock{
    [[WB_MessageManager shareMessageManager] requestPostWithAction:MechanismDetail dictionaryParam:self.teacherDetailParam withResultBlock:^(NSString *code, NSString *message, id data) {
        if (resultBlock) {
            resultBlock(code,message,data);
        }
    }];
}

//找老师
- (void)lookTeacherResultBlock:(WBRequestResultBlock)resultBlock{
    [[WB_MessageManager shareMessageManager] requestPostWithAction:MechanismTeacher dictionaryParam:self.lookTeacherParam withResultBlock:^(NSString *code, NSString *message, id data) {
        NSMutableArray *resultArray = [[NSMutableArray alloc] initWithCapacity:0];
        resultArray = data[@"data"][@"data"];
        if(resultArray.count > 0){
            [self.lookTeacherArray removeAllObjects];
            [self.lookTeacherArray addObjectsFromArray:resultArray];
            if(resultBlock){
                resultBlock(code,message,data);
            }
        }
        else{
            if(resultBlock){
                resultBlock(code, message, nil);
            }
        }
    }];
}

//教师课程
- (void)teacherCourseResultBlock:(WBRequestResultBlock)resultBlock{
    [[WB_MessageManager shareMessageManager] requestPostWithAction:MechanismTeacher_course dictionaryParam:self.teacherCourseParam withResultBlock:^(NSString *code, NSString *message, id data) {
        NSMutableArray *resultArray = [[NSMutableArray alloc] initWithCapacity:0];
        resultArray = data[@"data"][@"data"];
        if(resultArray.count > 0){
            [self.teacherCourseArray removeAllObjects];
            [self.teacherCourseArray addObjectsFromArray:resultArray];
            if(resultBlock){
                resultBlock(code,message,data);
            }
        }
        else{
            if(resultBlock){
                resultBlock(code, message, nil);
            }
        }
    }];
}
#pragma mark - getter,setter
//找老师详情
- (NSMutableDictionary *)teacherDetailParam{
    if (!_teacherDetailParam) {
        _teacherDetailParam = [[NSMutableDictionary alloc] initWithCapacity:0];
        [_teacherDetailParam setObject:[DATAMODEL.configDBHelper getToken]  forKey:@"token"];
        [_teacherDetailParam setObject:@"" forKey:@"id"];
    }
    return _teacherDetailParam;
}
//找老师
- (NSMutableDictionary *)lookTeacherParam{
    if (!_lookTeacherParam) {
        _lookTeacherParam = [[NSMutableDictionary alloc] initWithCapacity:0];
        [_lookTeacherParam setObject:@"" forKey:@"lat"];
        [_lookTeacherParam setObject:@"" forKey:@"lng"];
        [_lookTeacherParam setObject:@"" forKey:@"type"];
        [_lookTeacherParam setObject:[DATAMODEL.configDBHelper getToken] forKey:@"token"];
        [_lookTeacherParam setObject:@"" forKey:@"cate"];
    }
    return _lookTeacherParam;
}
- (NSMutableArray *)lookTeacherArray{
    if (!_lookTeacherArray) {
        _lookTeacherArray = [[NSMutableArray alloc] initWithCapacity:0];
    }
    return _lookTeacherArray;
}

//教师课程
- (NSMutableDictionary *)teacherCourseParam{
    if (!_teacherDetailParam) {
        _teacherDetailParam = [[NSMutableDictionary alloc] initWithCapacity:0];
        [_teacherDetailParam setObject:[DATAMODEL.configDBHelper getToken]  forKey:@"token"];
        [_teacherDetailParam setObject:@"" forKey:@"id"];
    }
    return _teacherDetailParam;
}
- (NSMutableArray *)teacherCourseArray{
    if (!_teacherCourseArray) {
        _teacherCourseArray = [[NSMutableArray alloc] initWithCapacity:0];
    }
    return _teacherCourseArray;
}
@end
